﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Configuration;
using Model;
using System.Data;

namespace DAL
{
  public  class FirmDAL
    {
        /// <summary>
        /// 链接数据库
        /// </summary>
        Database db = DatabaseFactory.CreateDatabase("constring");

        public List<Firm> CeShi()
        {
            DataSet ds = db.ExecuteDataSet(CommandType.Text, "select Firm_Id,Firm_Name from firm");
            List<Firm> li = new List<Firm>();
            DataTable dt=ds.Tables[0];
            foreach (DataRow item in dt.Rows)
            {
                Firm f = new Firm();
                f.Firm_Id = Convert.ToInt32(item["Firm_Id"]);
                f.Firm_Name = item["Firm_Name"].ToString();
                li.Add(f);
            }
            return li;
        }
    }
}
